import { ActiveBaseIcon } from "../activity/icon/ActiveBaseIcon";
import { LayerManager } from "../../manager/LayerManager";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ClockManager } from "../../manager/ClockManager";
import { SecTimer } from "../../../../com/gengine/core/frame/SecTimer";
import { TimerType } from "../../../../com/gengine/core/frame/TimerType";
import { RemainTimeTool } from "../award/RemainTimeTool";
import { MsgManager } from "../../manager/MsgManager";
import { HighlightManager } from "../../manager/HighlightManager";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
import { GLabel } from "../../../../com/mui/controls/GLabel";
type int = number;
//class SpaHintButton
    
    export  class SpaHintButton extends ActiveBaseIcon
    {
        constructor(arg1: Boolean=false)
        {
            super();
            this.layer = LayerManager.rightTopUILayer;
            this._isCross = arg1;
            this.createChildren();
            this.addListeners();
            return;
        }

        /* internal  */createChildren(): void
        {
            if (this._isCross) 
            {
                this._spaBtn = ObjCreate.createGLoadedButton(ResFileConst.CrossSpaIcon, 0, 0, 60, 50, this);
            }
            else 
            {
                this._spaBtn = ObjCreate.createGLoadedButton(ResFileConst.spaHintButton, 0, 0, 50, 50, this);
            }
            this._spaBtn.toolTipData = HTMLUtil.addColor(Language.getString(60700), "#FFFFFF");
            this._timeLabel = ObjCreate.createLabel("", 0, 50, 52, 20, flash.text.TextFormatAlign.CENTER, this, true, GlobalStyle.color1Uint);
            return;
        }

        /* internal  */addListeners(): void
        {
            this._spaBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onSpaHintButtonClick);
            return;
        }

        /* internal  */onSpaHintButtonClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.removeHighLightEffect();
            return;
        }

        public setTime(arg1: Date): void
        {
            this._time = (arg1.time - ClockManager.instance.nowDate.time) / 1000;
            this.startTimerCount();
            return;
        }

        /* internal  */startTimerCount(): void
        {
            if (!this._timer) 
            {
                this._timer = new SecTimer();
                this._timer.addListener(TimerType.ENTERFRAME, this.onTimerHandler);
                this._timer.start();
            }
            return;
        }

        /* internal  */onTimerHandler(arg1: SecTimer): void
        {
            --this._time;
            this._timeLabel.htmlText = RemainTimeTool.getRemainTimeBySeconds(this._time);
            if (this._time == 60) 
            {
                MsgManager.showRollTipsMsg(Language.getString(60352));
            }
            if (this._time == 30) 
            {
                MsgManager.showRollTipsMsg(Language.getString(60353));
            }
            if (this._time == 0) 
            {
                if (this._timer) 
                {
                    this._timer.stop();
                    this._timer = null;
                }
            }
            return;
        }

        public addHighLightEffect(): void
        {
            HighlightManager.instance.glowEffectButton(this, true);
            return;
        }

        public removeHighLightEffect(): void
        {
            HighlightManager.instance.glowEffectButton(this, false);
            return;
        }

        /* internal */ /* var */_time: int;

        /* internal */ /* var */_timer: SecTimer;

        /* internal */ /* var */_spaBtn: GLoadedButton;

        /* internal */ /* var */_timeLabel: GLabel;

        /* internal */ /* var */_isCross: Boolean;
    }
